package com.bcn.login_mybatisplus_demo.meal.controller;

import java.util.List;

import com.bcn.login_mybatisplus_demo.common.controller.BaseController;
import com.bcn.login_mybatisplus_demo.common.page.TableDataInfo;
import com.bcn.login_mybatisplus_demo.meal.domain.TAppMeal;
import com.bcn.login_mybatisplus_demo.meal.service.ITAppMealService;
import com.bcn.login_mybatisplus_demo.pojo.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * 【请填写功能名称】Controller
 * 
 * @author administrator
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/system/meal")
public class TAppMealController extends BaseController
{
    private String prefix = "system/meal";

    @Autowired
    private ITAppMealService tAppMealService;

    @GetMapping()
    public String meal()
    {
        return prefix + "/meal";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TAppMeal tAppMeal)
    {
        startPage();
        List<TAppMeal> list = tAppMealService.selectTAppMealList(tAppMeal);
        return getDataTable(list);
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @PostMapping("/add")
    public R addSave(@RequestBody TAppMeal tAppMeal)
    {
        return R.success(tAppMealService.insertTAppMeal(tAppMeal));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TAppMeal tAppMeal = tAppMealService.selectTAppMealById(id);
        mmap.put("tAppMeal", tAppMeal);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @PostMapping("/edit")
    public R editSave(@RequestBody TAppMeal tAppMeal)
    {
        return R.success(tAppMealService.updateTAppMeal(tAppMeal));
    }

    /**
     * 删除【请填写功能名称】
     */
    @GetMapping( "/remove/{id}")
    public R remove(@PathVariable("id") String id)
    {
        return R.success(tAppMealService.deleteTAppMealByIds(id));
    }
}
